package com.yhy.domain.vo;

import com.yhy.domain.UserInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.text.SimpleDateFormat;
import java.util.Date;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class MessageLike {
    private String id; //用户id
    private String avatar;
    private String nickname;
    private String createDate; //点赞，评论，喜欢的时间

    public static MessageLike init(UserInfo info, Long create) {
        MessageLike vo = new MessageLike();
        BeanUtils.copyProperties(info, vo);
        vo.setId(info.getId().toString());
        String createDate = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date(create));
        vo.setCreateDate(createDate);
        return vo;
    }
}